package com.travelsmart.client.apresentacao.view;

import java.util.List;



import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.travelsmart.client.apresentacao.controller.CommandController;
import com.travelsmart.client.apresentacao.controller.Observer;
import com.travelsmart.client.apresentacao.i18n.I18nMessages;
import com.travelsmart.client.apresentacao.view.subview.ViewInfoHotel;
import com.travelsmart.client.apresentacao.view.subview.ViewTableHotel;
import com.travelsmart.client.bean.to.FilterInfoHotel;
import com.travelsmart.client.bean.to.FilterPesquisaHotel;
import com.travelsmart.client.bean.to.HotelTO;
import com.travelsmart.client.bean.to.ParametroOrdenacao;

public class ViewListaHotel extends BaseView implements Observer<List<HotelTO>>{

	
	private final VerticalPanel panelViewListaHotel = new VerticalPanel();
	private final ViewInfoHotel viewInfoHotel = new ViewInfoHotel(new HTML(I18nMessages.INSTANCE.informacao()));
	private final ViewTableHotel viewTableHotel;

	public ViewListaHotel(final CommandController<FilterInfoHotel> handler1, final CommandController<ParametroOrdenacao> handler2) {
		super(new HTML(I18nMessages.INSTANCE.lista_hotel()));
		viewTableHotel = new ViewTableHotel(new HTML(""), handler1, handler2);
		initWidget(panelViewListaHotel);
	}

	public void exec(FilterPesquisaHotel filter, List<HotelTO> hoteis) {
		panelViewListaHotel.clear();
		viewTableHotel.exec(hoteis);
		viewInfoHotel.exec(filter);
		panelViewListaHotel.add(viewInfoHotel);
		panelViewListaHotel.add(viewTableHotel);
	}
	
	public void exec() {
		panelViewListaHotel.clear();
		panelViewListaHotel.add(viewInfoHotel);
		panelViewListaHotel.add(viewTableHotel);
	}
	
	public HTML getNome() {
		return this.nome;
	}

	public ViewInfoHotel getViewInfoHotel() {
		return viewInfoHotel;
	}

	public ViewTableHotel getViewTableHotel() {
		return viewTableHotel;
	}

	@Override
	public void update(List<HotelTO> arg) {
		exec();
		
	}
	
}
